package wadassignment2

import java.util.Date;
import java.util.List;

class Listing {

	String name;
	Date endDateTime;
	Float startingBid;
	String description;
	//List bids //for ordering
	static hasMany = [bids:Bid]
	static hasOne = [winner: Customer]
	static belongsTo = [seller: Customer]

	
//	static namedQueries = {
//		mostRecentBid {
//			bids {
//				def now = new Date()
//				//gt 'bid.creationDate', now - 365
//				//sqlRestriction "dateCreated = max(dateCreated)"
//			}
//		}
//	}
	
	static constraints = {
		name(blank: false, size:1..63)
		description(nullable:true, size:1..255)
		endDateTime(nullable: false,
				validator: {val, obj ->
					val > new Date()
				})


		winner(nullable:true)
		
	}

}
